package com.xveshe.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xveshe.common.annotation.Log;
import com.xveshe.common.core.controller.BaseController;
import com.xveshe.common.core.domain.AjaxResult;
import com.xveshe.common.enums.BusinessType;
import com.xveshe.admin.domain.XsglTstg;
import com.xveshe.admin.service.IXsglTstgService;
import com.xveshe.common.utils.poi.ExcelUtil;
import com.xveshe.common.core.page.TableDataInfo;

/**
 * 调社调岗Controller
 *
 * @author geyasong
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/admin/tstg")
public class XsglTstgController extends BaseController
{
    @Autowired
    private IXsglTstgService xsglTstgService;

    /**
     * 查询调社调岗列表
     */
    @GetMapping("/list")
    public TableDataInfo list(XsglTstg xsglTstg)
    {
        startPage();
        List<XsglTstg> list = xsglTstgService.selectXsglTstgList(xsglTstg);
        return getDataTable(list);
    }

    /**
     * 导出调社调岗列表
     */
    @PreAuthorize("@ss.hasPermi('admin:tstg:export')")
    @Log(title = "调社调岗", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XsglTstg xsglTstg)
    {
        List<XsglTstg> list = xsglTstgService.selectXsglTstgList(xsglTstg);
        ExcelUtil<XsglTstg> util = new ExcelUtil<XsglTstg>(XsglTstg.class);
        util.exportExcel(response, list, "调社调岗数据");
    }

    /**
     * 获取调社调岗详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(xsglTstgService.selectXsglTstgById(id));
    }

    /**
     * 新增调社调岗
     */
    @PreAuthorize("@ss.hasPermi('admin:tstg:add')")
    @Log(title = "调社调岗", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XsglTstg xsglTstg)
    {
        return toAjax(xsglTstgService.insertXsglTstg(xsglTstg));
    }

    /**
     * 修改调社调岗
     */
    @PreAuthorize("@ss.hasPermi('admin:tstg:edit')")
    @Log(title = "调社调岗", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XsglTstg xsglTstg)
    {
        return toAjax(xsglTstgService.updateXsglTstg(xsglTstg));
    }

    /**
     * 删除调社调岗
     */
    @PreAuthorize("@ss.hasPermi('admin:tstg:remove')")
    @Log(title = "调社调岗", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xsglTstgService.deleteXsglTstgByIds(ids));
    }
}
